﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="frmNotaPedido.aspx.cs" Inherits="Box.Cliente.Almacen.frmNotaPedido" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <style type="text/css">
        .auto-style1 {
            height: 47px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
     
      <div class="panel panel-primary">
    	<div class="panel-heading"><h3>Nota de Pedido</h3></div>
    	<div class="panel-body">
        <asp:TextBox runat="server" ID="txtCodigo" Visible="False"/>
            <table>
                <tr>
                    <td>
                        <label for="txtNroCompra">N° Compra</label>
                        <asp:TextBox runat="server" TextMode="Number" ID="txtNroCompra" CssClass="form-control input-sm" />
                    </td>
                    <td>
                        <label for="txtFecha">Fecha</label>
                        <asp:TextBox runat="server" ID="txtFecha"  CssClass="form-control input-sm"/>

                    </td>                  
                </tr>
                <tr>
                   <td>
                        <label>Estado</label>
                        <asp:DropDownList id="cbEstado" runat="server">
                        <asp:ListItem Value="Atendido">Atendido</asp:ListItem>
                        <asp:ListItem Value="No Atendido">No Atendido</asp:ListItem>
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                <td colspan="1"><label>Comentario</label><asp:TextBox runat="server" ID="txtComentario" Width="330px" Height="340" CssClass="form-control input-sm" TextMode="MultiLine"/></td>
                <td>
                    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                                    <ContentTemplate>
                                        <asp:ListView ID="lvDoc"
                                            ItemType="Box.Entities.NotaPedido"
                                            
                                            runat="server">
                                    <LayoutTemplate>
                                        <div id="itemPlaceholder" runat="server"></div>
                                    </LayoutTemplate>
                                    <ItemTemplate>
                                            <div class="row">
                                                <div class="item">
                                                      <iframe id="iframePDF" src="<%# string.Format("http://localhost:1202/Images/"+Item.DocumentoPedido)%>" style="width:800px; height:375px;" frameborder="1"></iframe>
                                                </div>
                                            </div>
                                    </ItemTemplate>
                                </asp:ListView>
                            </ContentTemplate>
                        </asp:UpdatePanel>
                    </td>
                </tr>
            </table>
            <br/><br/>
			<table>
			    <tr>
				    <td><label>Criterio:</label></td>
				    <td><asp:TextBox ID="txtCriterio" placeholder="Buscar" runat="server"/></td>
				    <td><asp:Button runat="server" CssClass="btn btn-primary btn-sm" Text="Buscar" ID="btnBuscar"/></td>
			    </tr>
			</table>
		    <br/><br/>
            <asp:UpdatePanel runat="server" ID="upProducto">
				<ContentTemplate>
					<asp:ListView ID="lvProductos"
							ItemType="Box.Entities.Producto" SelectMethod="GetProductos"
						runat="server" OnItemCommand="lvProductos_ItemCommand" >
						<EmptyDataTemplate>
							<b>No se han encontrado Productos..!!</b>
						</EmptyDataTemplate>
						<LayoutTemplate>
							<table class="table table-hover table-condensed">
								<thead>
									<tr>
										<th>Descripción</th>												
										<th>Precio</th>
										<th>Stock</th>
										<th>Acciones</th>
									</tr>
								</thead>
								<tbody>
									<tr id="itemPlaceholder" runat="server"/>
								</tbody>
								</table>
							<asp:DataPager ID="dpProductos" PagedControlID="lvProductos" runat="server" PageSize="2">
								<Fields>
									<asp:NextPreviousPagerField
										ButtonType="Link"
										ShowFirstPageButton="True"
										ShowLastPageButton="True"
										ShowNextPageButton="True"
										ShowPreviousPageButton="True"
										/>
								</Fields>
							</asp:DataPager>
						</LayoutTemplate>
						<ItemTemplate>
							<tr>
								<th><%# Item.NombreProducto %></th>										
								<th><%# Item.Precio %></th>
								<th><%# Item.TallaProducto %></th>
								<th>
									<asp:Button ID="btnAgregar"
										Text="Agregar" CommandName="AddDetalle"
										CommandArgument="<%# Item.Id %>"
										CssClass="btn btn-info btn-sm" runat="server"/>
								</th>
							</tr>
						</ItemTemplate>
					</asp:ListView>
				</ContentTemplate>
				<Triggers>
					<asp:AsyncPostBackTrigger ControlID="btnBuscar" EventName="Click"/>                            
				</Triggers>
			</asp:UpdatePanel>
    	    <br /><br/>
            <asp:UpdatePanel runat="server" ID="upDetalle">
				<ContentTemplate>
					<asp:ListView ID="lvDetalleNota" runat="server" OnItemCommand="lvDetalleNota_ItemCommand">
						<EmptyDataTemplate>
							<table class="table table-bordered table-striped table-hover table-condensed">
								<thead>
									<tr>
										<th>#</th>
										<th>Descripcion</th>
										<th>Cantidad</th>
										<th>Precio</th>
										<th>Monto</th>
										<th>Acciones</th>
									</tr>
								</thead>
								<tbody>
									<tr>
										<td colspan="6">
											<h3>No tiene productos agregados a su detalle..!!</h3>
										</td>
									</tr>
								</tbody>
								<tfoot>
									<tr>
										<td></td>
										<td></td>
										<td></td>
										<td></td>
										<td></td>
										<td></td>
									</tr>
								</tfoot>
							</table>
						</EmptyDataTemplate>
						<LayoutTemplate>
							<table class="table table-bordered table-striped table-hover table-condensed">
								<thead>
									<tr>
										<th style="width: 20px;">#</th>
										<th>Descripcion</th>
										<th>Cantidad</th>
										<th>Precio</th>
										<th>Monto</th>
										<th>Acciones</th>
									</tr>
								</thead>
								<tbody>
									<tr id="itemPlaceholder" runat="server"/>
								</tbody>
								<tfoot>
									<tr>
										<td>
											<%--<asp:Button runat="server"
												ID="btnActualizarDetalle"
												Text="Actualizar Detalle"
												CommandName="ActualizarDetalle" />--%>
										</td>
										<td></td>
										<td></td>
										<td><h3>Total:</h3></td>
										<td><h3><asp:Label ID="lblTotal" runat="server"></asp:Label></h3></td>
										<td></td>
									</tr>
								</tfoot>
							</table>
						</LayoutTemplate>                                
						<ItemTemplate>
							<tr>
								<td><%# Eval("Producto.Id") %></td>
								<td><%# Eval("Producto.NombreProducto") %></td>
								<td><asp:TextBox runat="server" AutoPostBack="False" ID="txtCantidad" OnTextChanged="txtCantidad_TextChanged"  Text='<%# Bind("Cantidad") %>' Width="50px"/></td>
								<td><asp:TextBox runat="server" ID="txtPrecio" AutoPostBack="False" OnTextChanged="txtPrecio_TextChanged" Text='<%# Bind("PrecioUnit") %>' Width="50px"/></td>
								<td><%# Eval("Monto") %></td>
								<td>
									<asp:Button ID="btnQuitar" runat="server" Text="Quitar"
										CssClass="btn btn-danger btn-sm"
										CommandName="QuitarDetalle"
										CommandArgument='<%# Eval("IdProducto") %>'/>
								</td>
							</tr>
						</ItemTemplate>
					</asp:ListView>
				</ContentTemplate>
				<Triggers>
					<asp:AsyncPostBackTrigger ControlID="lvDetalleNota" EventName="ItemCommand"/>
					<asp:AsyncPostBackTrigger ControlID="lvProductos" EventName="ItemCommand"/>
					<asp:AsyncPostBackTrigger ControlID="btnGuardar" EventName="Click"/>
				</Triggers>
			</asp:UpdatePanel>
    	</div>
    	<div class="panel-footer">
			<asp:Button runat="server" ID="btnGuardar" CssClass="btn btn-success" Text="Guardar" OnClick="btnGuardar_Click"/>
				<%-- <asp:Button runat="server" ID="btnLimpiar" CssClass="btn bg-info" Text="Limpiar"/>--%>
				<asp:Button ID="btnCancelar" runat="server" Text="Atrás" CssClass="btn btn-danger" OnClick="btnCancelar_Click" OnClientClick="return confirm('Desea  salir a Listar Notas Pedidos');"/>
		</div>
    </div>
</asp:Content>
